<?php
/* 
 * ********* CVS HEADER ********* 
 * 
 * $RCSfile: admmaskdroitnomadd.php,v $ 
 * $Date: 2005/10/21 12:58:07 $ 
 * $Revision: 1.3 $ 
 * 
 * ********* CVS HEADER ********* 
 */
if($action=="process"){
	if($nid==-1){
		$query = "INSERT INTO droitmasquenom (nom,description) VALUES ('$nom','$description')";
		@rportalrequete($query) or rportalerreur($query,"?op=");	
	}else if($nid>0){
		$query = "SELECT nom FROM droitmasquenom WHERE id='$nid'";
		$result=rportalrequete($query) or rportalerreur($query,"?op=");
		if($row=rportalligne($result)){
			$query = "UPDATE droitmasquenom SET nom='$nom',description='$description' WHERE id='$nid'";
			@rportalrequete($query) or rportalerreur($query,"?op=");
			$query = "UPDATE droitmasque SET nom_droit='$nom' WHERE nom_droit='{$row['nom']}'";
			@rportalrequete($query) or rportalerreur($query,"?op=");
			$query = "UPDATE masque_selection SET nom_droit='$nom' WHERE nom_droit='{$row['nom']}'";
			@rportalrequete($query) or rportalerreur($query,"?op=");
		}
	}
	header("Location: ?op=admmaskgest");
	exit;
}
$id=-1;
$nom = '';
$description = '';
if($nid!=''){
	$query = "SELECT * FROM droitmasquenom WHERE id='$nid'";
	$result=rportalrequete($query) or rportalerreur($query,"?op=");
	if($row=rportalligne($result)){
		$id = $row['id'];
		$nom = $row['nom'];
		$description = $row['description'];	
	}
}
require_once("module/TPLN/TPLN.php"); 
$TPLN = new TPLN; 
$TPLN->Open($op_basepath."tpl/admmaskdroitnomadd.html"); 
$TPLN->IncludeFile("header","environnement/$session[environnement]/header.php");
$TPLN->IncludeFile("footer","environnement/$session[environnement]/footer.php");

require_once(get_path_module("admin"));
$pc = new panneau_controle();
$pc->calculRubriqueParFonction('admmaskgest');
$TPLN->Parse("panneau_controle",$pc->retourneEntete());

$TPLN->Parse("nom",$nom);
$TPLN->Parse("description",$description);
$TPLN->parse("id",$id);
$TPLN->Write();
?>